home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 3 / Amiga Tools 3.iso / grafik / raytracing / magiccamera / rspheres / rspheres.mc < prev    next >
Text File  |  1993-06-18  |  8KB  |  318 lines

  1. ; This file Copyright 1994 Dan Wesnor
  2. ;
  3. ; This file may be freely distributed as long as no 
  4. ; information is changed, no charge is made for
  5. ; the file, and the archive in which the file was
  6. ; contained is distributed in tact.  Any violation 
  7. ; of these conditions requires written authorization 
  8. ; by the copyright holder.
  9.  
  10. /*
  11.     This is a script for the Magic Camera rendering system.
  12.     Magic Camera (MC) uses ray-tracing for realisting rendering
  13.     of shadows, reflections, and transparency.  It is in the
  14.     final phase of completion and should be released shortly.
  15.     Plans are for release as shareware with a nominal charge
  16.     for a full working version.
  17.  
  18.     See comments for a description of features.
  19.     Comments are either C-style (like this one), or a semi-colon
  20.     followed by text    ; like this.
  21. */
  22.  
  23. /*
  24.     Primitive object include triangles and parallelograms,
  25.     both of which may be phong smoothed, spheres, rings (or disks),
  26.     and planes.
  27.  
  28.     Compound objects, which allow complex shapes to be built,
  29.     include extrusions, spins, skin-over-frame, filled complex
  30.     2-d polygons (with holes), heightfields, boxes, and
  31.     polygon spheres.
  32.  
  33.     Available patterns are check, wood, marble, brick, 
  34.     several types of bitmap wraps, blotch, and clouds.
  35.  
  36.     Textures include waves and several type of bumpmaps.
  37.  
  38.     Lamps include point-source, directional, directional
  39.     spotlights (w/ beam width and beam falloff sharpness
  40.     controls), or spherical extended.
  41.  
  42.     Variables, which may be used in complex expressions, include
  43.     real numbers, integers, 3d-vectors, and arrays of reals, 2-d vectors, 
  44.     and 3-d vectors.  Variables and arrays may be used to facilitate
  45.     animation.
  46. */
  47.  
  48.  
  49. ; If you have enough memory, use the first psp_vsegs 
  50. ; If not, use the second
  51. int psp_vsegs = 12        ; Variables!  Allows easy location of key
  52. ;int psp_vsegs = 8        ; values at the top of the script, can
  53. int psp_hsegs = psp_vsegs * 2    ; be used in expressions to save
  54.                 ; you the trouble of hand-computing things.
  55.                 ; Can also be used for simple animation.
  56.  
  57. camera {
  58.     loc    <-30, 14, -10>    ; location of the camera
  59.     target    <0, 2.5, 0>    ; location to point at
  60.                 ; field-of-view, image resolution,
  61.                 ; and pixel aspect ratio may also
  62.                 ; be defined
  63.     hfov    35
  64. }
  65.  
  66. sky {
  67.     zenith    <0, 0, .5>    ; color of the sky straight up
  68.     horizon    <0, 0, .5>    ; color of the sky at the horizon
  69. }
  70.  
  71. lamp {
  72.     loc    <-60, 180, -40>    ; location of the lamp
  73.     color    <.8, .8, .8>    ; color of the lamp
  74.                 ; lamps may also be 'spotlight' type
  75.                 ; lamps or may cast 'fuzzy' shadows.
  76. }
  77.  
  78. lamp {
  79.     loc    <-30, 200, 90>    ; another lamp
  80.     color    <.8, .8, .8>
  81. }
  82.  
  83. color black {        ; create a 'color' type pattern and name it 'black'
  84.     diff    <0, 0, 0>    ; diffuse color (apparent color) in RGB
  85.     scoef    100        ; specular coefficient (hot spot size)
  86.     srefl    1        ; specular reflection (hot spot brightness)
  87. }
  88.  
  89. color white {        ; another 'color' called 'white'    
  90.     diff    <1, 1, 1>
  91.     scoef    100
  92.     srefl    1
  93. }
  94.  
  95. color red_mirror {    ; another 'color' called 'red_mirror'
  96.     diff    <.7, 0, 0>
  97.     refl    <.5, .5, .5>    ; this one is partially reflective
  98.     scoef    100
  99.     srefl    1
  100. }
  101.  
  102. color blue_mirror {
  103.     diff    <0, 0, .7>
  104.     refl    <.5, .5, .5>
  105.     scoef    100
  106.     srefl    1
  107. }
  108.  
  109. color yellow_mirror {
  110.     diff    <.7, .7, 0>
  111.     refl    <.5, .5, .5>
  112.     scoef    100
  113.     srefl    1
  114. }
  115.  
  116. color silver_mirror {
  117.     diff    <.5, .5, .5>
  118.     refl    <.7, .7, .7>
  119.     scoef    100
  120.     srefl    1
  121. }
  122.  
  123. iff "mapfiles/ctaany.iff" mc.map        ; load a bitmap for patterns
  124.  
  125. wrapsp redmc {        ; a wrapped pattern called 'redmc'
  126.     bitmap    mc.map        ; use the bitmap loaded above
  127.     patt    red_mirror    ; use characteristics of red mirror
  128.     sub    0 red_mirror    ; substitute the pattern 'red_mirror'
  129.                 ; for pen 0 in the iff bitmap
  130.     sub    1 white        ; same for pen 1
  131.     sub    2 black        ; pen 2
  132.     sub    3 black        ; pen 3
  133.     dodiff            ; any additional colors found in the
  134.                 ; bitmap will be applied to the
  135.                 ; 'diff' propery of 'red_mirror'
  136.     xrep    1        ; the pattern repeats itself once
  137.                 ; around the object's equator
  138.     yrep    1        ; and one between the poles
  139.     filter    1        ; turn bitmap pre-filtering off
  140. }
  141.     
  142. wrapsp yellowmc {    ; same as above w/ some colors changed
  143.     filter    1
  144.     bitmap    mc.map
  145.     patt    yellow_mirror
  146.     sub    0 yellow_mirror
  147.     sub    1 white
  148.     sub    2 black
  149.     sub    3 black
  150.     xrep    1
  151.     yrep    1
  152.     dodiff
  153. }
  154.     
  155. wrapsp bluemc {        ; same as above w/ some colors changed
  156.     filter    1
  157.     bitmap    mc.map
  158.     patt    blue_mirror
  159.     sub    0 blue_mirror
  160.     sub    1 white
  161.     sub    2 black
  162.     sub    3 black
  163.     xrep    1
  164.     yrep    1
  165.     dodiff
  166. }
  167.     
  168. wrapsp silvermc {    ; same as above w/ some colors changed
  169.     filter    1
  170.     bitmap    mc.map
  171.     patt    silver_mirror
  172.     sub    0 silver_mirror
  173.     sub    1 white
  174.     sub    2 black
  175.     sub    3 black
  176.     xrep    1
  177.     yrep    1
  178.     dodiff
  179. }
  180.     
  181.  
  182. color black_refl {        ; another 'color' called 'black_refl'
  183.     diff    <0, 0, 0>
  184.     refl    <.5, .5, .5>
  185.     scoef    100
  186. }
  187.  
  188. color white_refl {        ; another 'color' called 'white_refl'
  189.     diff    <.9, .9, .9>
  190.     refl    <.5, .5, .5>
  191.     scoef    100
  192. }
  193.  
  194. check squares {            ; a checkerboard pattern
  195.     patt1    black_refl    ; use 'black_refl' and
  196.     patt2    white_refl    ; 'white_refl' to form the pattern
  197.     xsize    2.5        ; the checks are 2.5
  198.     zsize    2.5        ; units square
  199. }
  200.  
  201. real floorsize = 100.0    ; this variable will be used to control
  202.             ; the size of the floor.  If this is changed
  203.             ; then the computations below will make
  204.             ; everything turn out ok.
  205.  
  206. paragram {        ; 'paragram' is short hand for parallelogram,
  207.             ; so this builds one of those
  208.     patt    squares        ; apply the pattern called 'squares'
  209.                 ; which is the checkerboard from above
  210.     loc    <-floorsize/2, 0, -floorsize/2>    ; the location of the
  211.                         ; parallelogram. it will
  212.                         ; have its center at <0,0,0>
  213.     v1    <floorsize, 0, 0>    ; v1 and v2 define the vectors to
  214.     v2    <0, 0, floorsize>    ; two vertices of the parallelogram.
  215.                     ; because of the geometrical definition
  216.                     ; of a parallelogram, the fourth vertex
  217.                     ; is at loc+v1+v2
  218. }
  219.  
  220.  
  221. real sphere_rad = 3.0    ; the radius of the spheres
  222.  
  223. object sphere_ob1    ; create an object called 'sphere_ob1'.
  224.             ; this is done primarily to allows the
  225.             ; object to be transformed and reproduced.
  226.             ; everything between here and 'endobject'
  227.             ; below belongs to 'sphere_ob1'
  228.  
  229. psphere {    ; a psphere is a polygon-based sphere
  230.     radius    sphere_rad    ; the radius of this sphere
  231.     loc    <0, 0, 0>    ; the center of the sphere
  232.     patt    yellowmc    ; apply the pattern 'yellowmc'
  233.     vsegs    psp_vsegs    ; these two define the number of
  234.     hsegs    psp_hsegs    ; segments used to build the sphere,
  235.                 ; i.e. the number of polygons
  236.     smooth            ; apply the phong smoothing routines
  237.                 ; to the psphere to make it look smooth
  238. }
  239.  
  240. endobject     ; the end of 'sphere_ob1'
  241.  
  242. lockobject sphere_ob1    ; lock the object into pattern space so that
  243.             ; as it is rotated, the pattern will not 
  244.             ; slide around on it
  245.  
  246. object sphere_ob    ; create an object called 'sphere_ob'
  247.  
  248. translate sphere_ob1 <sphere_rad/cos(30), sphere_rad, 0>
  249.             ; the above line translates sphere_ob1
  250.             ; into position to make it look as if it's
  251.             ; resting on the above parallelogram.
  252.  
  253. child sphere_ob1    ; make 'sphere_ob1' a 'child' of
  254.             ; 'sphere_ob'.  child object can
  255.             ; be transformed independently of
  256.             ; its parent, but will still
  257.             ; follow the parent transformations.
  258.  
  259. endobject     ; end of sphere_ob
  260.  
  261. lockobject sphere_ob    ; and lock it into pattern space
  262.  
  263. /*
  264. instance sphere_ob    ; a simple instance of 'sphere_ob'
  265.             ; simple drops it into the scene
  266. */
  267.  
  268. xrotate sphere_ob1 43    ; rotate sphere_ob1 so that the patterns
  269. yrotate sphere_ob1 275    ; don't line up too neatly
  270. zrotate sphere_ob1 154
  271. yrotate sphere_ob 120    ; rotate 'sphere_ob' 120 degrees, since we're
  272.             ; going to create a circle of three.
  273.  
  274. /*
  275. instance {    ; a more complex instance
  276.     object    sphere_ob
  277.     subpatt    yellowmc silvermc    ; substitute every occurence
  278.                     ; of 'yellowmc' with
  279.                     ; 'silvermc'.  allows instances
  280.                     ; of the same object to have 
  281.                     ; different colors
  282. }
  283. */
  284.  
  285. xrotate sphere_ob1 175    ; again rotate 'sphere_ob1' to 
  286. yrotate sphere_ob1 294    ; 'unalign' the patterns
  287. zrotate sphere_ob1 32
  288. yrotate sphere_ob 120    ; and rotate into position
  289.  
  290. /*
  291. instance {    ; and instance it, but blue this time
  292.     object    sphere_ob
  293.     subpatt    yellowmc bluemc
  294. }
  295. */
  296.  
  297. object sphere_2        ; create another object called 'sphere_2'
  298.  
  299. psphere {
  300.     radius    sphere_rad    ; the radius
  301.     loc    <0, sphere_rad*(1+sin(60)+cos(60)), 0>
  302.         ; if my geometry is correct (not a good bet)
  303.         ; the above line positions the sphere on top 
  304.         ; of the three just created
  305.     patt    redmc        ; apply the 'redmc' pattern
  306.     vsegs    psp_vsegs
  307.     hsegs    psp_hsegs
  308.     smooth
  309. }
  310.  
  311. endobject     ; end it
  312.  
  313. lockobject sphere_2    ; lock it
  314.  
  315. yrotate sphere_2 225    ; rotate it so the text in the pattern is 
  316.             ; visible
  317. instance sphere_2    ; and drop it into the scene
  318.